package cn.tedu.rms.type.controller;

import cn.tedu.rms.base.response.JsonResult;
import cn.tedu.rms.type.pojo.dto.TypeQuery;
import cn.tedu.rms.type.pojo.dto.TypeSaveParam;
import cn.tedu.rms.type.pojo.vo.TypeVO;
import cn.tedu.rms.type.service.TypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "菜品分类管理")
@RequestMapping("/v1/dishType")
public class TypeController {
    @Autowired
    TypeService typeService;

    @ApiOperation(value = "查询菜品分类信息")
    @GetMapping("/select")
    public JsonResult selectType(TypeQuery typeQuery){
        log.debug("查询菜品分类信息:参数={}",typeQuery);
        List<TypeVO> list=typeService.selectType(typeQuery);
        return JsonResult.ok(list);
    }
    @ApiOperation(value = "保存菜品分类（增/该）信息")
    @PostMapping("/save")
    public JsonResult save(TypeSaveParam typeSaveParam){
        log.debug("保存菜品分类信息:参数={}",typeSaveParam);
        typeService.save(typeSaveParam);
        return JsonResult.ok();
    }


    @ApiOperation(value = "删除菜品分类信息")
    @PostMapping("/delete/{id}")
    public JsonResult deleteType(@PathVariable Long id){
        log.debug("删除菜品分类信息:参数={}",id);
        typeService.deleteType(id);
        return JsonResult.ok();
    }

}
